﻿using Microsoft.Xna.Framework;

namespace ShevaEngine.Core.Modules.Models
{
    /// <summary>
    /// Mesh part.
    /// </summary>
    public class ShevaMesh
    {
        /// <summary>Transformace meshe.</summary>
        public Matrix Transform;
        /// <summary>Geometrie.</summary>
        public ShevaModelGeometry[] Geometries;

        //public MaterialParameters mParameters;

        /// <summary>
        /// Konstruktor.
        /// </summary>
        public ShevaMesh()
        {

        }

        /// <summary>
        /// Metoda inicializuje model.
        /// </summary>
        /// <param name="model"></param>
        public void Init(ShevaModel model)
        {
            foreach (ShevaModelGeometry geometry in this.Geometries)
                geometry.Init(model);

            //this.mParameters = new MaterialParameters();
            //this.mParameters.Add("World",  this.Transform);
        }

        ///// <summary>
        ///// Metoda vrati viditelne objekty.
        ///// </summary>
        ///// <param name="rState"></param>
        ///// <param name="visibleObjects"></param>
        //public void GetVisibleObjects(RendererState rState, RenderingPipeline pipeline,
        //    Matrix transformation)
        //{
        //    MaterialParameters temp = this.mParameters.Clone();
        //    temp["World"] = this.Transform * transformation;            

        //    foreach (ShevaGeometry geometry in this.Geometries)
        //        //if (rState.Camera.Frustum.Intersects(geometry.BoundingBox))
        //           // if (geometry.Material[rState.RenderType.ToString()].CastShadows)
        //                pipeline.AddObject(rState, geometry.Material, geometry, temp);
        //}
    }
}
